package com.briup.product_source.controller;

import com.briup.product_source.pojo.DiseaseRecord;
import com.briup.product_source.pojo.ManagerDisease;
import com.briup.product_source.pojo.ext.DiseaseRecordExt;
import com.briup.product_source.result.Result;
import com.briup.product_source.service.DiseaseRecordService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "病症记录模块")
@RestController
@RequestMapping("/diseaseRecord")
public class DiseaseController {

    @Autowired
    private DiseaseRecordService diseaseRecordService;


    @ApiOperation("分页多条件查询栏舍信息接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前页码", defaultValue = "1", required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页大小", defaultValue = "10", required = true),
            @ApiImplicitParam(name = "drStatus",value = "治疗状态"),
            @ApiImplicitParam(name = "drDId",value = "病症")
    })
    @GetMapping
    public Result queryAllDisease(Integer pageNum, Integer pageSize,String drStatus,Integer drDId){
        PageInfo<DiseaseRecordExt> pageInfo = diseaseRecordService.queryAllDisease(pageNum,pageSize,drStatus,drDId);
        return Result.success(pageInfo);
    }

    @ApiOperation("获取所有病症接口")
    @GetMapping("/queryAllDisease")
    public Result queryAllAndSelect(){
        List<ManagerDisease> list = diseaseRecordService.queryAllAndSelect();
        return Result.success(list);
    }


    @ApiOperation("添加或修改功能接口")
    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdate(@RequestBody DiseaseRecord diseaseRecord){
        diseaseRecordService.saveOrUpdate(diseaseRecord);
        return Result.success();
    }


    @ApiOperation("单个删除功能接口")
    @DeleteMapping("/deleteById/{id}")
    public Result deleteOne(@PathVariable Integer id){
        diseaseRecordService.deleteById(id);
        return Result.success();
    }

    @ApiOperation("批量删除功能接口")
    @DeleteMapping("/deleteByIdAll")
    public Result deleteAll(@RequestBody List<Integer> ids){
        diseaseRecordService.deleteByChoice(ids);
        return Result.success();
    }
}
